﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ChequeManagement.BLL
{
    /// <summary>
    /// This Class contains number of Field,enum , properties,method and this class inheritance of BaseObject class
    /// </summary>
    /// <field> this field use in IsValid method</field>
    /// <properties>this properties contain set for receive value and contain get for return value </properties>
    ///  <method>this class contain IsValid method for Validation all properties</method>
    ///  <enum>this enum contains DrawerID,DrawerName,Tel,Address</enum>
    public class BLLDrawer : BaseObject
    {
        private string tableName = "Drawer";

        /// <summary>
        ///  This enum include some member
        /// </summary>
        public enum DrawerField
        {
            DrawerID,
            DrawerName,
            Tel,
            Address
        }
        private int drawerID;
        private string drawerName;
        private string tel;
        private string address;

        /// <summary>
        /// This property contain set for receive value and use of ToUpper() method for convert lower char to large and contain get for return value
        /// </summary>
        public string Address
        {
            get
            {
                return address;
            }
            set
            {
               address = value.ToUpper();
            }



        }
        
       /// <summary>
        /// This property contain set for receive value and contain get for return value
       /// </summary>
        public int DrawerID
        {
            get
            {

                return drawerID;
            }
            set
            {
               drawerID = value;
            }

        }
     
       /// <summary>
        /// This property contain set for receive value and use of ToUpper() method for convert lower char to large and contain get for return value
       /// </summary>
        public string DrawerName
        {
            get
            {

                return drawerName;
            }
            set
            {
               drawerName = value.ToUpper();
            }
        }
    

          /// <summary>
        /// This property contain set for receive value and contain get for return value
          /// </summary>
        public string Tel
        {
            get
            {
                return tel;
            }
            set
            {
                tel = value;
            }
        }

        /// <summary>
        /// This method check fields value
        /// </summary>
        /// <param name="excepts" Type="string[]"></param>
        /// <DrawerName>this method check DrawerName field if DrawerName value is null or value is WhiteSpace,this method add error</DrawerName>
        /// <Tel>this method check Tel field if Tel value length large of 100,this method add error</Tel>
        /// <Address>this method check Address field if Address value is null or value is WhiteSpace,this method add error</Address>
        /// <returns>if all field is Valid,ErrorsCount value is zero and return true else ErrorsCount value Larger of zero and return false</returns>
        public bool IsValid(params string[] excepts)
        {
            if (string.IsNullOrWhiteSpace(DrawerName))
                AddError("عنوان نام خالی می باشد", null);
            else
            {
                if (DrawerName.Length > 100)
                    AddError("طول عنوان بانک نباید بیشتر از {0} کاراکتر باشد", 100);
             
            }

            if (string.IsNullOrWhiteSpace(Tel))
                AddError("عنوان تلفن خالی می باشد", null);
            else
            {
                if (Tel.Length > 11)
                    AddError("طول تلفن نباید بیشتر از {0} کاراکتر باشد", 11);
               
            }

            if (string.IsNullOrWhiteSpace(Address))
                AddError("عنوان آدرس خالی می باشد", null);
            else
            {
                if (Address.Length > 700)
                    AddError("طول آدرس نباید بیشتر از {0} کاراکتر باشد", 700);
            }


            if (ErrorsCount > 0)
                return false;
            else
                return true;
        
        }
      

    }
}
